package com.ft.oa.web.development;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ft.oa.domain.development.DevProduct;
import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.service.development.DevProductService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 研发-产品-接口
 */
@RestController
@RequestMapping("/dev/product")
public class DevProductController {

    @Resource
    private DevProductService productService;

    /**
     * 研发-产品数量统计
     * @return
     */
    @GetMapping("/count")
    public ApiResult count(){

        ApiResult result = productService.count();

        return result;

    }

    /**
     * 研发-产品分页
     * @param product
     * @return
     */
    @PostMapping("/page")
    public ApiResult page(@RequestBody DevProduct product){

        Page<ArrayList<DevProduct>> page = productService.page(product);

        return ApiResult.successWithData(page);

    }

    /**
     * 产品-新增
     * @param product
     * @return
     */
    @PostMapping("/add")
    public ApiResult add(@RequestBody DevProduct product){

        ApiResult result = productService.add(product);

        return result;

    }


    /**
     * 产品-更新
     * @param product
     * @return
     */
    @PostMapping("/update")
    public ApiResult update(@RequestBody DevProduct product){

        ApiResult result = productService.update(product);

        return result;

    }

    /**
     * 产品-删除
     * @param product
     * @return
     */
    @PostMapping("/del")
    public ApiResult del(@RequestBody DevProduct product){

        ApiResult result = productService.del(product);

        return result;

    }

    /**
     * 产品列表
     * @return
     */
    @GetMapping("/list")
    public ApiResult list(){

        List<DevProduct> result = productService.list();

        return ApiResult.successWithData(result);
    }
}
